var e = require("../../utils/api.js"), o = getApp(), a = require("../../utils/disapi.js");

Page({
    data: {
        authorize: !0
    },
    onLoad: function(e) {
        console.log(e);
        var o = this, a = decodeURIComponent(e.url);
        console.log(a), o.setData({
            url: a
        });
    },
    bindGetUserInfo: function (t) {
        var n = this;
        if (console.log(t.detail.userInfo), t.detail.userInfo) {
            var i = "";
            wx.getStorage({
                key: "pid",
                success: function(e) {
                    if (console.log(e.data), i = e.data, console.log(i), "" != i && void 0 != i) {
                        var o = wx.getStorageSync("openid");
                        a.check_user({
                            openid: o
                        }).then(function(e) {
                            console.log(e), 0 == e.errno && (e.data ? a.get_group_bing({
                                openid: o,
                                pid: i
                            }) : (a.get_group_bing({
                                openid: o,
                                pid: i
                            }), a.get_commoned_bing({
                                openid: o,
                                pid: i
                            })), wx.removeStorage({
                                key: "pid",
                                success: function(e) {
                                    console.log(e.data);
                                }
                            }));
                        });
                    }
                }
            });
            var r = {
                avatarUrl: t.detail.userInfo.avatarUrl,
                nickName: t.detail.userInfo.nickName,
                openid: wx.getStorageSync("openid"),
                sessionkey: wx.getStorageSync("sessionkey")
            };
            e.inserUserdata(r).then(function(e) {
                n.setData({
                    authorize: !1
                }), console.log(n.data.url), o.globalData.is_first_enter = 2, "back" == n.data.url ? wx.navigateBack({
                    delta: 1
                }): wx.redirectTo({
                    url: "/" + n.data.url
                });
            });
        } else wx.showToast({
            title: "授权失败",
            icon: "none",
            duration: 2e3
        }), n.setData({
            authorize: !0
        }) , wx.redirectTo({
          url: "/pages/personal/personal"
        });
  },
});